@extends('admin.index')
@section('title','审核列表')
 @section('con')

 <div class="panel-body">
     <div class="dataTable_wrapper">
         <div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
             

      <div class="row">
       <div class="col-sm-12">
         <table id="dataTables-example" class="table table-striped table-bordered table-hover dataTable no-footer" role="grid" aria-describedby="dataTables-example_info">
             <thead>
                 <tr role="row"><th class="sorting_asc" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 157px;" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending">ID</th><th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 182px;" aria-label="Browser: activate to sort column ascending">用户名(非昵称)</th><th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 165px;" aria-label="Platform(s): activate to sort column ascending">广告图片</th><th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 134px;" aria-label="Engine version: activate to sort column ascending">权限</th><th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 96px;" aria-label="CSS grade: activate to sort column ascending">链接</th><th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 96px;" aria-label="CSS grade: activate to sort column ascending">剩余时间</th><th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 96px;" aria-label="CSS grade: activate to sort column ascending">操作</th></tr>
             </thead>
             <tbody>
              @foreach($ad as $k=>$v)

                <tr class="gradeA odd" role="row">
                     <td class="sorting_1">{{$v->id}}</td>
                     <td> <?php if(empty($v->uid)){?> 管理员<?php }else{?>上传者<?php } ?></td>
                     <td><img src="{{$v->content}}" style="width:550px;height:100px;" alt=""></td>
                     <td>
                     <?php if(empty($v->adopt)){?>  <?php if(empty($v->adopt)){?>
                            <button class="btn btn-default" data-toggle="modal"  data-target="#myModal{{$v->id}}">待审核</button>
                     <?php }?><?php }else if(($v->adopt)==2){?><p style="color:red">审核未通过</p><?php }else{?> <p style="color:green">审核通过</p> <?php } ?>
                     </td>
                     <td>{{$v->url}}</td>
                   <td><?php if((($v->ctime)-time())<0){echo'<p style="color:red">广告已到期</p>';}else{
     echo(date('z天',($v->ctime)-time()));}
      ?></td>
                     <td class="center">
                         <a href="/admin/ad/del?id={{$v->id}}" >删除</a>|
                         <button class="btn btn-link" data-toggle="modal" data-target="#myModaldd{{$v->id}}">
修改
</button>
                     </td>
                </tr>

              @endforeach
            </tbody>
         </table>
     </div>
    </div>
         <div class="row">
             <div class="col-sm-6">
                 <!-- <div class="dataTables_info" id="dataTables-example_info" role="status" aria-live="polite">Showing 1 to 25 of 57 entries</div> -->
             </div>
             <div class="col-sm-6">
              @foreach($ad as $k=>$v)
                <!-- 修改模态框 -->
<div class="modal fade" id="myModaldd{{$v->id}}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">修改</h4>
      </div>
      <form class="form-horizontal"  role="form" method="post" action="{{url('/admin/ad/update')}}"  enctype="multipart/form-data">
      <div class="modal-body">
         <h2>广告图片</h2>
         <input  type="file" name="content"  id='content' value="">
        <img src="{{$v->content}}" style='width:500px;height:50px;' alt="">
        <h2>跳转链接</h2>
        <input type="text" class="form-control" id="url" name='url' value='{{$v->url}}' placeholder="输入广告链接">
        <input type="hidden" id='id' name='id' value='{{$v->id}}'>
         {{ csrf_field() }}
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="submit" class="btn btn-primary">提交</button>
      </div>
      </form>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

                <!-- 审核模态框 -->
<div class="modal fade" id="myModal{{$v->id}}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div style='padding-top:40px;padding-left:20px;'>
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">广告</h4>
      </div>
      <div class="modal-body">
      <h4> 图片:</h4> <img src="{{$v->content}}" style="width:1200px;height:100px;" alt=""><br>
    <h4>链接: </h4><h2><p>{{$v->url}}</p> </h2>
            <a class="btn btn-success" href="/admin/ad/success?id={{$v->id}}">通过</a>
        <a class="btn btn-danger" href="/admin/ad/danger?id={{$v->id}}">未通过</a>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>

      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
                 @endforeach
             </div>
         </div>
         </div>
     </div>
     
 </div>
 @endsection
 @section('js')
    <script type="text/javascript">
        $('.delUser').click(function(){
            
            //获取id
            var id = $(this).attr('sid');
            var bb = $(this);
            
             $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
                });
            //发送post请求
            $.post('/admin/user/delete',{id:id},function(data){
                if(data == 1){

                    //删除单条信息
                    bb.parents('tr').remove();

                    //获取提醒信息
                    $('#successMessage').text('用户删除成功').show(1000);
                        //定时关闭消息
                        setTimeout(function(){
                            $('#successMessage').hide(1000);
                        },2000);

                }
            });
            return false;
        })
    </script>
 @endsection

